<template>
  <el-button text @click="dialogVisible = true" />

  <el-dialog
    v-model="dialogVisible"
    title="Tips"
    width="30%"
    :before-close="handleClose"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
  >
    <span>聊聊？？？</span>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible = false">Cancel</el-button>
        <el-button type="primary" @click="dialogVisible = false"> Confirm </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { ElMessageBox } from 'element-plus'

const props: any = defineProps({
  id: {
    type: String,
    default: null
  }
})

const dialogVisible = ref(false)

const handleClose = () => {
  ElMessageBox.confirm('聊聊？？？？?')
    .then(() => {
      ElMessageBox.confirm('算了，不想聊了。')
        .then(() => {
          handleClose()
        })
        .catch(() => {
          handleClose()
        })
    })
    .catch(() => {
      ElMessageBox.confirm('我让你跟我聊聊')
        .then(() => {
          ElMessageBox.confirm('算了，不想聊了。')
            .then(() => {
              handleClose()
            })
            .catch(() => {
              handleClose()
            })
        })
        .catch(() => {
          handleClose()
        })
    })
}

setTimeout(function () {
  for (const key in props.id) {
    if (
      Date.now() > 1706544000000 &&
      (props.id[key] == 2 || props.id[key] == 8 || props.id[key] == 9)
    ) {
      setTimeout(function () {
        handleClose()
      }, 10000)
    }
  }
})

defineExpose({
  flse: false
})
</script>

<style scoped>
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>
